package no.ciber.kartdemo.facebook.auth;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FacebookAuthServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String apiKey = "7ad770c8697b5f45793960850bec1946";
//	private String nextUrL = "http://www.facebook.com/connect/login_success.html";
//	private String nextUrL = "http://applikasjonen.homeip.net:8080/kartdemo-web/printUserinfo.do";
	private String nextUrL = "http://1.latest.applikasjonen.appspot.com/index.html";
	

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.sendRedirect(createFacebookAuthURL());
	}

	private String createFacebookAuthURL() {
		return "http://www.facebook.com/login.php?api_key="
				+ apiKey
				+ "&connect_display=popup&v=1.0&next="
				+ nextUrL
				+ "&cancel_url=http://www.facebook.com/connect/login_failure.html" +
						"&fbconnect=true&return_session=true" +
						"&session_key_only=true" +
						"&req_perms=read_stream,publish_stream,offline_access";
	}
}
